package net.jlibrary.invoice.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.BatchSize;

import net.jlibrary.common.core.annotation.CodeGenComment;
import net.jlibrary.common.core.annotation.SearchCondition;
import net.jlibrary.common.core.annotation.SearchField;
import net.jlibrary.common.core.entity.BaseObject;

@Entity(name = "tab_goods")
//@SeePurview(value = "member.group.globalPath")
@BatchSize(size = 15)
@CodeGenComment(value = "商品编码信息", genSelect = false, add = false, update = false, delete = false)
public class Goods extends BaseObject {
	private static final long serialVersionUID = -7201010404058565662L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@SearchField(value = "id", condition = SearchCondition.EQUAL)
	private Long id;

	@Column(length = 19)
	@CodeGenComment(value = "税局规定的商品编码", viewList = true, required = true)
	@SearchField(value = "spbm", condition = SearchCondition.EQUAL)
	private String spbm;

	@Column(length = 20)
	@SearchField(value = "nsrsbh", condition = SearchCondition.EQUAL)
	@CodeGenComment(value = "纳税人编号", viewList = true, required = true)
	private String nsrsbh;

	@Column(length = 90)
	@SearchField(value = "spmc", condition = SearchCondition.FUZZ_FULL)
	@CodeGenComment(value = "商品名称", viewList = true, required = true)
	private String spmc;

//	@ManyToOne(fetch = FetchType.LAZY)
//	@JoinColumn(name = "group_id")
//	@SearchField(value = "group", condition = SearchCondition.EQUAL)
//	@CodeGenComment(value = "所属机构")
//	private Group group;

//	@Column(length = 3)
//	@CodeGenComment(value = "税率", viewList = true, required = true)
//	private Double sl;// 税率

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "slKind_id")
	@CodeGenComment(value = "税率类型 ", viewList = true, required = true)
	private SlKind slKind;// 税率类型

	@CodeGenComment(value = "单价", viewList = true, required = true)
	private Double dj;// 单价

	@Column(length = 20)
	@CodeGenComment(value = "商品税目", viewList = true, required = true)
	private String spsm;

	@Column(length = 1)
	@CodeGenComment(value = "优惠政策标识", viewList = true, required = true)
	private String yhzcbs;// 0未使用;1使用

	@Column(length = 1)
	@CodeGenComment(value = "零税率标识", viewList = true, required = true)
	private String lslbs;// 空 代表无 1 出口免税和其他免税优惠政策 2 不征增值税 3 普通零税率

	@Column(length = 500)
	@CodeGenComment(value = "增值税特殊管理", viewList = true, required = true)
	private String zzstsgl;// 如果yhzcbs为1时，此项必填

	@Column(length = 20)
	@CodeGenComment(value = "单位", viewList = true, required = true)
	private String dw;

	@Column(length = 40)
	@CodeGenComment(value = "规格型号", viewList = true, required = true)
	private String ggxh;

	@Column(updatable = false)
	@Temporal(TemporalType.TIMESTAMP)
	@CodeGenComment(value = "创建时间", viewList = true)
	private Date createdate;
	@Temporal(TemporalType.TIMESTAMP)
	private Date lastdate;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getSpbm() {
		return spbm;
	}

	public void setSpbm(String spbm) {
		this.spbm = spbm;
	}

	public String getSpmc() {
		return spmc;
	}

	public void setSpmc(String spmc) {
		this.spmc = spmc;
	}

	public String getSpsm() {
		return spsm;
	}

	public void setSpsm(String spsm) {
		this.spsm = spsm;
	}

	public String getYhzcbs() {
		return yhzcbs;
	}

	public void setYhzcbs(String yhzcbs) {
		this.yhzcbs = yhzcbs;
	}

	public String getLslbs() {
		return lslbs;
	}

	public void setLslbs(String lslbs) {
		this.lslbs = lslbs;
	}

	public String getZzstsgl() {
		return zzstsgl;
	}

	public void setZzstsgl(String zzstsgl) {
		this.zzstsgl = zzstsgl;
	}

	public String getDw() {
		return dw;
	}

	public void setDw(String dw) {
		this.dw = dw;
	}

	public Double getDj() {
		return dj;
	}

	public void setDj(Double dj) {
		this.dj = dj;
	}

	public String getGgxh() {
		return ggxh;
	}

	public void setGgxh(String ggxh) {
		this.ggxh = ggxh;
	}

	public Date getCreatedate() {
		return createdate;
	}

	public void setCreatedate(Date createdate) {
		this.createdate = createdate;
	}

	public Date getLastdate() {
		return lastdate;
	}

	public void setLastdate(Date lastdate) {
		this.lastdate = lastdate;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getNsrsbh() {
		return nsrsbh;
	}

	public void setNsrsbh(String nsrsbh) {
		this.nsrsbh = nsrsbh;
	}

	public SlKind getSlKind() {
		return slKind;
	}

	public void setSlKind(SlKind slKind) {
		this.slKind = slKind;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Goods other = (Goods) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

	@Override
	public Serializable getPrimaryKey() {
		// TODO Auto-generated method stub
		return id;
	}

}
